package com.bailiban;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zhulang
 * @Classname SwaggerConfig
 * @Description TODO
 * @Date 2020/3/27 19:46
 */
@Configuration
@EnableSwagger2
@ComponentScan("com.bailiban.controller")
@ConditionalOnExpression(value = "${swagger.enbale}")
public class SwaggerConfig {
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any()).build();
    }

    public ApiInfo apiInfo() {
        return new ApiInfoBuilder().title("COVID-19接口文档")
                .description("新冠肺炎疫情项目开发接口文档")
                .contact(new Contact("浪哥", null, "917257515@qq.com"))
                .version("1.0.0").build();
    }
}
